<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>BIP.Bayes.Melding.FitModel</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="BIP-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bayesian-inference">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="BIP-module.html">Package&nbsp;BIP</a> ::
        <a href="BIP.Bayes-module.html">Package&nbsp;Bayes</a> ::
        <a href="BIP.Bayes.Melding-module.html">Module&nbsp;Melding</a> ::
        Class&nbsp;FitModel
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="BIP.Bayes.Melding.FitModel-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class FitModel</h1><p class="nomargin-top"><span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel">source&nbsp;code</a></span></p>
Fit a model to data generating
Bayesian posterior distributions of input and
outputs of the model.

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="BIP.Bayes.Melding.FitModel-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">K</span>,
        <span class="summary-sig-arg">L</span>,
        <span class="summary-sig-arg">model</span>,
        <span class="summary-sig-arg">ntheta</span>,
        <span class="summary-sig-arg">nphi</span>,
        <span class="summary-sig-arg">inits</span>,
        <span class="summary-sig-arg">tf</span>,
        <span class="summary-sig-arg">phinames</span>,
        <span class="summary-sig-arg">thetanames</span>,
        <span class="summary-sig-arg">wl</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">nw</span>=<span class="summary-sig-default">1</span>,
        <span class="summary-sig-arg">verbose</span>=<span class="summary-sig-default">False</span>)</span><br />
      Initialize the model fitter.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="BIP.Bayes.Melding.FitModel-class.html#set_priors" class="summary-sig-name">set_priors</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">pdists</span>,
        <span class="summary-sig-arg">ppars</span>,
        <span class="summary-sig-arg">tdists</span>,
        <span class="summary-sig-arg">tpars</span>)</span><br />
      Set the prior distributions for Phi and Theta</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.set_priors">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_init_priors"></a><span class="summary-sig-name">_init_priors</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">prior</span>=<span class="summary-sig-default">None</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel._init_priors">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="do_inference"></a><span class="summary-sig-name">do_inference</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">prior</span>,
        <span class="summary-sig-arg">data</span>,
        <span class="summary-sig-arg">predlen</span>,
        <span class="summary-sig-arg">method</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.do_inference">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="BIP.Bayes.Melding.FitModel-class.html#run" class="summary-sig-name">run</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">data</span>,
        <span class="summary-sig-arg">method</span>,
        <span class="summary-sig-arg">monitor</span>=<span class="summary-sig-default">False</span>)</span><br />
      Fit the model against data</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.run">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_monitor_setup"></a><span class="summary-sig-name">_monitor_setup</span>(<span class="summary-sig-arg">self</span>)</span><br />
      Sets up realtime plotting of inference</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel._monitor_setup">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_monitor_plot"></a><span class="summary-sig-name">_monitor_plot</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">series</span>,
        <span class="summary-sig-arg">prior</span>)</span><br />
      Plots real time data</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel._monitor_plot">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="plot_results"></a><span class="summary-sig-name">plot_results</span>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">names</span>=<span class="summary-sig-default">[]</span>)</span><br />
      Plot the final results of the inference</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.plot_results">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_read_results"></a><span class="summary-sig-name">_read_results</span>(<span class="summary-sig-arg">self</span>)</span><br />
      read results from disk</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel._read_results">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">K</span>,
        <span class="sig-arg">L</span>,
        <span class="sig-arg">model</span>,
        <span class="sig-arg">ntheta</span>,
        <span class="sig-arg">nphi</span>,
        <span class="sig-arg">inits</span>,
        <span class="sig-arg">tf</span>,
        <span class="sig-arg">phinames</span>,
        <span class="sig-arg">thetanames</span>,
        <span class="sig-arg">wl</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">nw</span>=<span class="sig-default">1</span>,
        <span class="sig-arg">verbose</span>=<span class="sig-default">False</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  Initialize the model fitter.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>K</code></strong> - Number of samples from the priors. On MCMC also the number of samples of the posterior.</li>
        <li><strong class="pname"><code>L</code></strong> - Number of samples of the posteriors. Only used on SIR and ABC methods.</li>
        <li><strong class="pname"><code>model</code></strong> - Callable (function) returning the output of the model, from a set of parameter values received as argument.</li>
        <li><strong class="pname"><code>ntheta</code></strong> - Number of parameters included in the inference.</li>
        <li><strong class="pname"><code>nphi</code></strong> - Number of outputs of the model.</li>
        <li><strong class="pname"><code>inits</code></strong> - inits initial values for the model's variables.</li>
        <li><strong class="pname"><code>tf</code></strong> - Length of the simulation, in units of time.</li>
        <li><strong class="pname"><code>phinames</code></strong> - List of names (strings) with names of the model's variables</li>
        <li><strong class="pname"><code>thetanames</code></strong> - List of names (strings) with names of parameters included on the inference.</li>
        <li><strong class="pname"><code>wl</code></strong> - window lenght length of the inference window.</li>
        <li><strong class="pname"><code>nw</code></strong> - Number of windows to analyze on iterative inference mode</li>
        <li><strong class="pname"><code>verbose</code></strong> - Verbose output if True.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="set_priors"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">set_priors</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">pdists</span>,
        <span class="sig-arg">ppars</span>,
        <span class="sig-arg">tdists</span>,
        <span class="sig-arg">tpars</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.set_priors">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  Set the prior distributions for Phi and Theta
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>pdists</code></strong> - distributions for the output variables. For example: [scipy.stats.uniform,scipy.stats.norm]</li>
        <li><strong class="pname"><code>ppars</code></strong> - paramenters for the distributions in pdists. For example: [(0,1),(0,1)]</li>
        <li><strong class="pname"><code>tdists</code></strong> - same as pdists, but for input parameters (Theta).</li>
        <li><strong class="pname"><code>tpars</code></strong> - same as ppars, but for tdists.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="run"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">run</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">data</span>,
        <span class="sig-arg">method</span>,
        <span class="sig-arg">monitor</span>=<span class="sig-default">False</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="BIP.Bayes.Melding-pysrc.html#FitModel.run">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  Fit the model against data
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>data</code></strong> - dictionary with variable names and observed series, as Key and value respectively.</li>
        <li><strong class="pname"><code>method</code></strong> - Inference method: &quot;ABC&quot;, &quot;SIR&quot; or &quot;MCMC&quot;</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="BIP-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bayesian-inference">Project Homepage</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Thu Jan  7 10:45:33 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
